
package com.theme.passport.controller.sys;

import com.theme.common.mvc.utils.PageUtils;
import com.theme.common.mvc.view.R;
import com.theme.passport.entity.SysFriendlyLinkEntity;
import com.theme.passport.service.SysFriendlyLinkService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;



/**
 * 友情链接
 *
 * @author live
 * @email 870459550@qq.com
 * @date 2020-12-08 15:14:01
 */
@RestController
@RequestMapping("sys/friendly-link")
public class SysFriendlyLinkController {
    @Autowired
    private SysFriendlyLinkService sysFriendlyLinkService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:friendly-link:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sysFriendlyLinkService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:friendly-link:info")
    public R info(@PathVariable("id") Integer id){
		SysFriendlyLinkEntity sysFriendlyLink = sysFriendlyLinkService.getById(id);

        return R.ok().put("friendlyLink", sysFriendlyLink);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:friendly-link:save")
    public R save(@RequestBody SysFriendlyLinkEntity sysFriendlyLink){
        sysFriendlyLink.setCreateTime(new Date());
        sysFriendlyLink.setUpdateTime(new Date());
		sysFriendlyLinkService.save(sysFriendlyLink);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:friendly-link:update")
    public R update(@RequestBody SysFriendlyLinkEntity sysFriendlyLink){
		sysFriendlyLinkService.updateById(sysFriendlyLink);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:friendly-link:delete")
    public R delete(@RequestBody Integer[] ids){
		sysFriendlyLinkService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
